#include "util.h"

int RegrexMatching(const char *pattern,const char *src ,regmatch_t pm[]){
	int iMax  = 10 ;
	int iMacthCnt = 0;
	regex_t preg;
	const char *st;
	if(NULL == pattern || NULL == src){
		return -1;
	}
	if (regcomp(&preg, pattern, REG_EXTENDED |REG_NEWLINE) != 0){ //编译正则表达式
		return -1;
	}
	st = src;
	while (st && regexec(&preg, st, iMax, pm, REG_NOTEOL) != REG_NOMATCH){ //开始匹配
		st = &st[pm[3].rm_eo];    //转到下一个匹配的初始位置
		iMacthCnt ++;
	}

	return iMacthCnt;
}

